package com.ranjith.struts2.actions;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.Action;
import com.ranjith.struts2.beans.User;

public class LoginAction implements SessionAware{
	private User user;
	private Map session;
	
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Map getSession() {
		return session;
	}

	
	public String execute(){
		System.out.println("login execute");
		System.out.println(user.getUsername());
		System.out.println(user.getPassword());
		if("a".equalsIgnoreCase(user.getUsername()) && "a".equalsIgnoreCase(user.getPassword())){
			System.out.println("auth method");
			session.put("user", user);
			return "success";
		}
		return "loginfail";
	}

	@Override
	public void setSession(Map session) {
		this.session = session;		
	}
	
}
